let fs = require("fs");//加载fs模块
let user = { username:"admin1",password:"12345" };
function login(){
    let data=fs.readFileSync(__dirname+"/persons.json", "utf8")
    let arr = JSON.parse(data.toString());
    let flag=arr.findIndex((v)=>{
        return v.username==user.username&&v.password==user.password
    })
    if (flag!=-1) {
        console.log('登录成功');
    }else{
        console.log('用户名和密码错误');
    }
}
login()
